package com.example;

import de.greenrobot.daogenerator.DaoGenerator;
import de.greenrobot.daogenerator.Entity;
import de.greenrobot.daogenerator.Schema;

public class MyClass {

    public static void main(String[] args) {
        // 创建Schema对象
        // 构造方法第一个参数为数据库版本号
        // 第二个参数为自动生成的实体类将要存放的位置,前面为我的Android Module的包名
        Schema schema = new Schema(4, "com.uhylab.uhuvinetest.dao");
        // 添加需要创建的实体类信息
        addNote(schema);
        try {
            // 创建实体类.第二个参数填Android Module的路径
            new DaoGenerator().generateAll(schema, "./app/src/main/java");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 添加将要创建的实体类的信息,会根据类名生成数据库的表,属性名生成数据库的字段<p>
     * 当然如果想建多张表,可以创建多个Entity对象
     *
     * @param schema
     */
    private static void addNote(Schema schema) {
        // 指定需要生成实体类的类名,类名确定了那么表名也是根据这个类名来自动命名的,例如下面这个,生成的表名叫做person_entity
        Entity entity = schema.addEntity("UserDataEntity");
        // 指定自增长主键
        // 添加类的属性,根据属性生成数据库表中的字段
        entity.addStringProperty("id");
        entity.addStringProperty("name");
        entity.addStringProperty("sex");
        entity.addStringProperty("birthday");
        entity.addStringProperty("weight");
        entity.addStringProperty("height");
        entity.addStringProperty("booldType");
        entity.addStringProperty("telephone");
        Entity localHistory = schema.addEntity("LocalHistory");
        // 指定自增长主键
        // 添加类的属性,根据属性生成数据库表中的字段
        localHistory.addIdProperty().autoincrement().primaryKey();
        localHistory.addStringProperty("telephone");
        localHistory.addStringProperty("leukocytes");
        localHistory.addStringProperty("leukocytes_status");
        localHistory.addStringProperty("nitrite_status");
        localHistory.addStringProperty("nitrite");
        localHistory.addStringProperty("urobilinogen_status");
        localHistory.addStringProperty("urobilinogen");
        localHistory.addStringProperty("protein_status");
        localHistory.addStringProperty("protein");
        localHistory.addStringProperty("ph_status");
        localHistory.addStringProperty("ph");
        localHistory.addStringProperty("blood_status");
        localHistory.addStringProperty("blood");
        localHistory.addStringProperty("gravity_status");
        localHistory.addStringProperty("gravity");
        localHistory.addStringProperty("ketones_status");
        localHistory.addStringProperty("ketones");
        localHistory.addStringProperty("bilirubin_status");
        localHistory.addStringProperty("bilirubin");
        localHistory.addStringProperty("glucose_status");
        localHistory.addStringProperty("glucose");
        localHistory.addStringProperty("ascorbicacid_status");
        localHistory.addStringProperty("ascorbicacid");
        localHistory.addStringProperty("log");
        localHistory.addStringProperty("lat");
        localHistory.addStringProperty("date");

        Entity cloudHistory = schema.addEntity("CloudHistory");
        // 指定自增长主键
        // 添加类的属性,根据属性生成数据库表中的字段
        cloudHistory.addIdProperty().autoincrement().primaryKey();
        cloudHistory.addStringProperty("telephone");
        cloudHistory.addStringProperty("leukocytes");
        cloudHistory.addStringProperty("leukocytes_status");
        cloudHistory.addStringProperty("nitrite_status");
        cloudHistory.addStringProperty("nitrite");
        cloudHistory.addStringProperty("urobilinogen_status");
        cloudHistory.addStringProperty("urobilinogen");
        cloudHistory.addStringProperty("protein_status");
        cloudHistory.addStringProperty("protein");
        cloudHistory.addStringProperty("ph_status");
        cloudHistory.addStringProperty("ph");
        cloudHistory.addStringProperty("blood_status");
        cloudHistory.addStringProperty("blood");
        cloudHistory.addStringProperty("gravity_status");
        cloudHistory.addStringProperty("gravity");
        cloudHistory.addStringProperty("ketones_status");
        cloudHistory.addStringProperty("ketones");
        cloudHistory.addStringProperty("bilirubin_status");
        cloudHistory.addStringProperty("bilirubin");
        cloudHistory.addStringProperty("glucose_status");
        cloudHistory.addStringProperty("glucose");
        cloudHistory.addStringProperty("ascorbicacid_status");
        cloudHistory.addStringProperty("ascorbicacid");
        cloudHistory.addStringProperty("log");
        cloudHistory.addStringProperty("lat");
        cloudHistory.addStringProperty("createtime");


        Entity dis_history = schema.addEntity("UserDisHistoryEntity");

        dis_history.addStringProperty("history");
        dis_history.addIdProperty().autoincrement().primaryKey();
    }
}
